from flask import request

def log_middleware(app):
    @app.before_request
    def before_request():
        print("Before Request:", request.url)

    @app.after_request
    def after_request(response):
        print("After Request:", response.status_code)
        return response

def auth_middleware(app):
    @app.before_request
    def check_auth():
        # 模拟权限检查
        if request.path == '/admin' and not request.args.get('token') == 'secret':
            return "Unauthorized", 403